import subprocess
import os
 
def acl_run(op_type, inputs_path, inputs_info, outputs_info, attr, device_id, op_dir, is_dynamic=0, inplace_input_index={}, run_profiling_mode="acl"):
    if run_profiling_mode == "acl":
        cmd = ["python3", "tools/acl_execute.py"]
        params = ["--op_type=%s" % op_type, "--inputs_path=%s" % str(inputs_path), "--inputs_info=%s" % str(inputs_info),
                "--outputs_info=%s" % str(outputs_info), "--attrs=%s" % str(attr), "--device_id=%s" % device_id,
                "--op_model_path=%s" % op_dir, "--is_dynamic=%s" % is_dynamic, "--inplace_input_index=%s" % inplace_input_index,
                "--run_profiling_mode=%s" % run_profiling_mode]
        cmd.extend(params)
        try:
            subprocess.run(cmd, timeout=60000)
        except Exception as e:
            print(e)
    else:
        print("\033[31m[> error <]\033[0m" + "你输入的run_profiling_mode有问题, 有三种选项:'acl', 传入的是%s" % run_profiling_mode)
        sys.exit(1)